package nc.ui.arap.badacc;

import java.text.DecimalFormat;

import nc.vo.pub.BusinessException;

public class OnAddLineButtonHandler extends ButtonOnClickHandler {

    private DstlCaseMainPanel mainPanel;
	
	public OnAddLineButtonHandler(DstlCaseMainPanel mainPanel) {
		this.mainPanel = mainPanel;
	}

	public DstlCaseMainPanel getMainPanel() {
		return mainPanel;
	}

	@Override
	protected void handleEvent() throws BusinessException {
		if (getMainPanel().isCard()) {
			getMainPanel().getBillCardUIPanel().getBillListPanel().getHeadBillModel().addLine();
			if (getMainPanel().getBillCardUIPanel().getCaseCode() != null) {
				int row = getMainPanel().getBillCardUIPanel().getBillListPanel().getHeadTable().getRowCount() - 1;
				DecimalFormat format = new DecimalFormat("000");
				getMainPanel().getBillCardUIPanel().getBillListPanel().getHeadBillModel().setValueAt(getMainPanel().getBillCardUIPanel().getCaseCode() 
						+ format.format(row + 1), row, "num");
			}
		}

	}

	@Override
	protected void updateBtns() {

	}

}
